package com.hmdp.service.impl;

import com.hmdp.service.KafkaProducer;

import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.stereotype.Service;

@Service
public class KafkaProducerImpl implements KafkaProducer {
    private final KafkaTemplate<String,String> kafkaTemplate;


    public KafkaProducerImpl(KafkaTemplate<String,String> kafkaTemplate){
        this.kafkaTemplate = kafkaTemplate;
    }
    @Override
    public void sendMessage(String topic, String msg) {
        kafkaTemplate.send(topic,msg);
        System.out.println("topic = " + topic+" msg = "+msg);
    }
}
